﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:my="clr-namespace:AgiliTrain.PhoneyTools.Controls"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
                    mc:Ignorable="d">
  <Style TargetType="my:SelectSwitch">
    <Setter Property="Background"
            Value="{StaticResource TransparentBrush}" />
    <Setter Property="BorderBrush"
            Value="{StaticResource PhoneBorderBrush}" />
    <Setter Property="Foreground"
            Value="{StaticResource PhoneForegroundBrush}" />
    <Setter Property="IndicatorBrush"
            Value="{StaticResource PhoneAccentBrush}" />
    <Setter Property="TextIndicatorFontSize"
            Value="{StaticResource PhoneFontSizeSmall}" />
    <Setter Property="TextIndicatorFontFamily"
            Value="Segoe WP Light" />
    <Setter Property="TextIndicatorFontWeight"
            Value="Normal" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="my:SelectSwitch">
          <Grid Background="{TemplateBinding Background}"
                d:DesignWidth="489"
                d:DesignHeight="85"
                MinHeight="85"
                MinWidth="100">
            <VisualStateManager.VisualStateGroups>
              <VisualStateGroup x:Name="SwitchStates">
                <VisualState x:Name="OnState">
                  <Storyboard>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                   Storyboard.TargetName="indicatorLight">
                      <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                          <Visibility>Visible</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                      </DiscreteObjectKeyFrame>
                    </ObjectAnimationUsingKeyFrames>
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="OffState" />
              </VisualStateGroup>
              <VisualStateGroup x:Name="CommonStates">
                <VisualState x:Name="NormalState" />
                <VisualState x:Name="DisabledState">
                  <Storyboard>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                   Storyboard.TargetName="disabledFrame">
                      <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                          <Visibility>Visible</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                      </DiscreteObjectKeyFrame>
                    </ObjectAnimationUsingKeyFrames>
                  </Storyboard>
                </VisualState>
              </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="Auto"
                                MinWidth="80" />
              <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <ContentPresenter Grid.Column="1"
                              Margin="{TemplateBinding Margin}"
                              Content="{TemplateBinding Content}"
                              HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                              VerticalAlignment="{TemplateBinding VerticalAlignment}" />
            <Grid x:Name="Switch"
                  Background="{StaticResource TransparentBrush}"
                  MinWidth="76">
              <Rectangle RadiusY="3.75"
                         RadiusX="3.75"
                         Margin="{StaticResource PhoneMargin}"
                         Fill="{StaticResource PhoneChromeBrush}" />
              <Rectangle RadiusY="3.75"
                         RadiusX="3.75"
                         StrokeThickness="0.2"
                         Margin="{StaticResource PhoneMargin}"
                         Stroke="{TemplateBinding BorderBrush}" />
              <Rectangle x:Name="indicatorLight"
                         Margin="18,20,18,0"
                         RadiusY="3.75"
                         RadiusX="3.75"
                         StrokeThickness="0.5"
                         Height="8"
                         VerticalAlignment="Top"
                         Fill="{TemplateBinding IndicatorBrush}"
                         Visibility="Collapsed" />
              <Rectangle x:Name="indicatorFrame"
                         Margin="18,20,18,0"
                         RadiusY="3.75"
                         RadiusX="3.75"
                         StrokeThickness="0.5"
                         Height="8"
                         VerticalAlignment="Top">
                <Rectangle.Stroke>
                  <RadialGradientBrush RadiusY="1.096"
                                       RadiusX="1.019"
                                       Center="0.195,-0.098"
                                       GradientOrigin="0.265,0.15">
                    <GradientStop Color="Black"
                                  Offset="0.689" />
                    <GradientStop Color="White"
                                  Offset="1" />
                  </RadialGradientBrush>
                </Rectangle.Stroke>
              </Rectangle>
              <TextBlock x:Name="TextIndicator"
                         Margin="18,16,18,0"
                         Text="on"
                         FontFamily="Segoe WP Light"
                         FontSize="{StaticResource PhoneFontSizeSmall}"
                         TextAlignment="Center"
                         HorizontalAlignment="Center"
                         VerticalAlignment="Center"
                         Foreground="{TemplateBinding Foreground}" />
              <Rectangle x:Name="disabledFrame"
                         RadiusY="3"
                         RadiusX="3"
                         StrokeThickness="0.2"
                         Margin="{StaticResource PhoneMargin}"
                         Opacity="0.9"
                         Visibility="Collapsed"
                         Stroke="{StaticResource PhoneChromeBrush}">
                <Rectangle.Fill>
                  <SolidColorBrush Color="{StaticResource PhoneChromeColor}" />
                </Rectangle.Fill>
              </Rectangle>
            </Grid>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="TextIndicatorFontStretch"
            Value="Condensed" />
    <Setter Property="TextIndicatorBrush"
            Value="{StaticResource PhoneForegroundBrush}" />
  </Style>
  <ControlTemplate x:Key="PhoneDisabledTextBoxTemplate"
                   TargetType="TextBox">
    <ContentControl x:Name="ContentElement"
                    BorderThickness="0"
                    HorizontalContentAlignment="Stretch"
                    Margin="{StaticResource PhoneTextBoxInnerMargin}"
                    Padding="{TemplateBinding Padding}"
                    VerticalContentAlignment="Stretch" />
  </ControlTemplate>
  <Style x:Key="ClearableTextBox"
         TargetType="TextBox">
    <Setter Property="FontFamily"
            Value="{StaticResource PhoneFontFamilyNormal}" />
    <Setter Property="FontSize"
            Value="{StaticResource PhoneFontSizeMediumLarge}" />
    <Setter Property="Background"
            Value="{StaticResource PhoneTextBoxBrush}" />
    <Setter Property="Foreground"
            Value="{StaticResource PhoneTextBoxForegroundBrush}" />
    <Setter Property="BorderBrush"
            Value="{StaticResource PhoneTextBoxBrush}" />
    <Setter Property="SelectionBackground"
            Value="{StaticResource PhoneAccentBrush}" />
    <Setter Property="SelectionForeground"
            Value="{StaticResource PhoneTextBoxSelectionForegroundBrush}" />
    <Setter Property="BorderThickness"
            Value="{StaticResource PhoneBorderThickness}" />
    <Setter Property="Padding"
            Value="2" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="TextBox">
          <Grid Background="Transparent">
            <VisualStateManager.VisualStateGroups>
              <VisualStateGroup x:Name="CommonStates">
                <VisualState x:Name="Normal" />
                <VisualState x:Name="MouseOver" />
                <VisualState x:Name="Disabled">
                  <Storyboard>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                   Storyboard.TargetName="EnabledBorder">
                      <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                          <Visibility>Collapsed</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                      </DiscreteObjectKeyFrame>
                    </ObjectAnimationUsingKeyFrames>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                   Storyboard.TargetName="DisabledOrReadonlyBorder">
                      <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                          <Visibility>Visible</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                      </DiscreteObjectKeyFrame>
                    </ObjectAnimationUsingKeyFrames>
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="ReadOnly">
                  <Storyboard>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                   Storyboard.TargetName="EnabledBorder">
                      <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                          <Visibility>Collapsed</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                      </DiscreteObjectKeyFrame>
                    </ObjectAnimationUsingKeyFrames>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                   Storyboard.TargetName="DisabledOrReadonlyBorder">
                      <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                          <Visibility>Visible</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                      </DiscreteObjectKeyFrame>
                    </ObjectAnimationUsingKeyFrames>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"
                                                   Storyboard.TargetName="DisabledOrReadonlyBorder">
                      <DiscreteObjectKeyFrame KeyTime="0"
                                              Value="{StaticResource PhoneTextBoxBrush}" />
                    </ObjectAnimationUsingKeyFrames>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush"
                                                   Storyboard.TargetName="DisabledOrReadonlyBorder">
                      <DiscreteObjectKeyFrame KeyTime="0"
                                              Value="{StaticResource PhoneTextBoxBrush}" />
                    </ObjectAnimationUsingKeyFrames>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"
                                                   Storyboard.TargetName="DisabledOrReadonlyContent">
                      <DiscreteObjectKeyFrame KeyTime="0"
                                              Value="{StaticResource PhoneTextBoxReadOnlyBrush}" />
                    </ObjectAnimationUsingKeyFrames>
                  </Storyboard>
                </VisualState>
              </VisualStateGroup>
              <VisualStateGroup x:Name="FocusStates">
                <VisualState x:Name="Focused">
                  <Storyboard>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"
                                                   Storyboard.TargetName="EnabledBorder">
                      <DiscreteObjectKeyFrame KeyTime="0"
                                              Value="{StaticResource TransparentBrush}" />
                    </ObjectAnimationUsingKeyFrames>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush"
                                                   Storyboard.TargetName="EnabledBorder">
                      <DiscreteObjectKeyFrame KeyTime="0"
                                              Value="{StaticResource TransparentBrush}" />
                    </ObjectAnimationUsingKeyFrames>
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="Unfocused" />
              </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Border x:Name="EnabledBorder"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    Background="{TemplateBinding Background}">
              <ContentControl x:Name="ContentElement"
                              BorderThickness="0"
                              HorizontalContentAlignment="Stretch"
                              Margin="{StaticResource PhoneTextBoxInnerMargin}"
                              Padding="{TemplateBinding Padding}"
                              VerticalContentAlignment="Stretch" />
            </Border>
            <Border x:Name="DisabledOrReadonlyBorder"
                    BorderBrush="{StaticResource PhoneDisabledBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    Background="Transparent"
                    Margin="{StaticResource PhoneTouchTargetOverhang}"
                    Visibility="Collapsed">
              <TextBox x:Name="DisabledOrReadonlyContent"
                       Background="Transparent"
                       Foreground="{StaticResource PhoneDisabledBrush}"
                       FontWeight="{TemplateBinding FontWeight}"
                       FontStyle="{TemplateBinding FontStyle}"
                       FontSize="{TemplateBinding FontSize}"
                       FontFamily="{TemplateBinding FontFamily}"
                       IsReadOnly="True"
                       SelectionForeground="{TemplateBinding SelectionForeground}"
                       SelectionBackground="{TemplateBinding SelectionBackground}"
                       TextAlignment="{TemplateBinding TextAlignment}"
                       TextWrapping="{TemplateBinding TextWrapping}"
                       Text="{TemplateBinding Text}"
                       Template="{StaticResource PhoneDisabledTextBoxTemplate}" />
            </Border>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <Style TargetType="my:ClearableTextBox">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="my:ClearableTextBox">
          <Grid Background="{StaticResource TransparentBrush}"
        		d:DesignWidth="293"
        		d:DesignHeight="82">
        		<Grid.ColumnDefinitions>
        			<ColumnDefinition />
        			<ColumnDefinition Width="Auto" />
        		</Grid.ColumnDefinitions>
        		<VisualStateManager.VisualStateGroups>
        			<VisualStateGroup x:Name="FocusGroup">
        				<VisualState x:Name="Unfocused"/>
        				<VisualState x:Name="Focused">
        					<Storyboard>
        						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="focusBack">
        							<DiscreteObjectKeyFrame KeyTime="0">
        								<DiscreteObjectKeyFrame.Value>
        									<Visibility>Visible</Visibility>
        								</DiscreteObjectKeyFrame.Value>
        							</DiscreteObjectKeyFrame>
        						</ObjectAnimationUsingKeyFrames>
        						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="unfocusBack">
        							<DiscreteObjectKeyFrame KeyTime="0">
        								<DiscreteObjectKeyFrame.Value>
        									<Visibility>Collapsed</Visibility>
        								</DiscreteObjectKeyFrame.Value>
        							</DiscreteObjectKeyFrame>
        						</ObjectAnimationUsingKeyFrames>
        					</Storyboard>
        				</VisualState>
        			</VisualStateGroup>
        		</VisualStateManager.VisualStateGroups>
        		<Rectangle x:Name="focusBack" Fill="{StaticResource PhoneTextBoxEditBackgroundBrush}"
        			Stroke="{StaticResource PhoneTextBoxEditBorderBrush}"
        			Grid.ColumnSpan="2"
        			Margin="{StaticResource PhoneMargin}"
        			StrokeThickness="{StaticResource PhoneStrokeThickness}" Visibility="Collapsed" />
        		<Rectangle x:Name="unfocusBack" Fill="{StaticResource PhoneSubtleBrush}"
        			Stroke="{StaticResource TransparentBrush}"
        			Grid.ColumnSpan="2"
        			Margin="{StaticResource PhoneMargin}"
        			StrokeThickness="{StaticResource PhoneStrokeThickness}" />
        		<TextBox x:Name="TheTextBox"
        			Background="{x:Null}"
        			BorderBrush="{x:Null}"
        			Style="{StaticResource ClearableTextBox}"
        			Margin="{StaticResource PhoneMargin}" />
        		<Border BorderBrush="{StaticResource PhoneChromeBrush}"
        			Background="{StaticResource TransparentBrush}"
        			BorderThickness="2"
        			x:Name="ClearButton"
        			Grid.Column="1"
        			Margin="12,24,24,24"
        			Padding="6" Width="32" Height="32">
        			<Path StrokeThickness="3"
        				Stroke="{StaticResource PhoneChromeBrush}"
        				Data="M 0,0 L 25,25 M 0,25 L 25,0"
        				Stretch="UniformToFill"
        				UseLayoutRounding="False" />
        		</Border>
        	</Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="MinWidth" Value="160"/>
    <Setter Property="MinHeight" Value="80"/>
  </Style>
</ResourceDictionary>
